package exercises;

/**
 * Created by lauraionescu on 10/04/2014.
 */
public class DiamondExercises {
    public static void main(String [] args){
        printIsoscelesTriangle(3, false);
        System.out.println();
        printDiamond(5);
        System.out.println();
        printNameDiamond(4);
    }

    public static void printIsoscelesTriangle(int n, boolean exceptLastLine){

        int stopAt = n;
        if (exceptLastLine)
            stopAt = n-1;

        for (int i = 0; i < stopAt; i++){
            for (int j = i; j < n-1; j++)
                System.out.print(" ");
            for (int j = 0; j<(i*2+1); j++)
                System.out.print("*");
            System.out.println();
        }
    }

    public static void printReversedTriangle(int n){
        for (int i = n-1; i > 0; i--){
            for (int j = n-1; j >= i; j--)
                System.out.print(" ");
            for (int j = (i*2-1); j>0; j--)
                System.out.print("*");
            System.out.println();
        }
    }


    public static void printDiamond(int n){
        printIsoscelesTriangle(n, false);
        printReversedTriangle(n);
    }

    public static void printNameDiamond(int n){
        printIsoscelesTriangle(n, true);
        System.out.println("Bill");
        printReversedTriangle(n);
    }
}
